home *** CD-ROM | disk | FTP | other *** search
/ Aminet 3 / Aminet 3 - July 1994.iso / Aminet / gfx / misc / startdia.lha / ShowDia.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1994-02-01  |  9.4 KB  |  267 lines

  1. /*
  2.  * ShowDia.rexx   (Version 1.1 - 13 December 1993)
  3.  *                (Added Scrolling capabilities!)
  4.  *
  5.  * View assorted pictures on your Piccolo card with the Dia program. 
  6.  * This script is based on Alexander Pratsch his DO-Dia.rexx script.
  7.  * Text display and (mouse) wait support added by Paul Kolenbrander.
  8.  *
  9.  * This program will load a picture into Dia and will display the filename
  10.  * of this picture in the upperleft corner in a font and size specified by
  11.  * the user.  Also the user may choose to either specify a Delay time as a
  12.  * Tooltype or use the left mousebutton to determine when the next picture
  13.  * should be loaded. The scripts defaults to a 1 second wait period.
  14.  *
  15.  * Arguments: name   - Path and filename of picture to view.
  16.  *            font   - name of font to use, eg. magneto.font
  17.  *                     (Do not forget the .font addition)
  18.  *            size   - Size of font to use. If you specify a non-existing
  19.  *                     font, the program will substitute and existing one.
  20.  *            wait   - Delay to show the next picture in 50th of a second.
  21.  *                     When the user enters 0,  then this script will wait
  22.  *                     for a press on that left mousebutton before showing
  23.  *                     the next picture. (Default is 1 second wait.)
  24.  * 
  25.  * Make sure font & size is specified if the wait parameter is to be used.
  26.  * If you don't want text, just specify 0 0 x.  Where x is the wait value.
  27.  * That way the script won't show the filename,  but it'll wait for you to
  28.  * click the mouse. (if x is 0) Or delay the specified amount of time if x
  29.  * is greater than 0.
  30.  *
  31.  * Newly added feature... When you select a delay period by mouse-click (delay = 0)
  32.  * you can now scroll around pictures that are larger than the screen. All around 
  33.  * the screen are 25 pixel wide invisibale scroll bars. Click in the appropriate one 
  34.  * and the picture will scroll 25 pixels out of that direction... Click anywhere in
  35.  * the picture outside those scrollbars and the next picture is loaded. Where you 
  36.  * can also scroll around in. 
  37.  *
  38.  * NOTE: Scrolling only works when the loaded picture is LARGER than the screen it is
  39.  *       displayed in... And only those hidden parts can be scrolled into sight.
  40.  *
  41.  *                    Screen & Scroll Bar lay-out...
  42.  *                      
  43.  *             +--------------------------------------+ -
  44.  *             |  |         Scroll Down            |  | | 25 pixels wide
  45.  *             |S |--------------------------------| S| - 
  46.  *             |c |                                | c|
  47.  *             |r |                                | r|
  48.  *             |o |                                | o|
  49.  *             |l |             Exit               | l|
  50.  *             |l |            Scroll              | l|
  51.  *             |  |           Routine.             |  |
  52.  *             |R |                                | L|
  53.  *             |i |                                | e|
  54.  *             |g |                                | f|
  55.  *             |h |                                | t|
  56.  *             |t |--------------------------------|  | -
  57.  *             |  |         Scroll Up              |  | | 25 pixels wide
  58.  *             +--------------------------------------+ - 
  59.  *             |--|                                |--|
  60.  *             25 pixels wide                   25 pixels wide
  61.  *
  62.  *
  63.  * - Installing this script into Directory-Opus.
  64.  *
  65.  * Call up the Directory Opus Configuration program.
  66.  *
  67.  * Make sure you specify 'AmigaDOS' and enter the below line in the string
  68.  * gadget:
  69.  *
  70.  * rx s:ShowDia.rexx {f} [<fontname> <fontsize> <waitperiod>]
  71.  *
  72.  * where [....] are optional values. See the arguments discussion above.
  73.  *
  74.  * Example: rx:ShowDia.rexx {f} topaz.font 9 0
  75.  *
  76.  * Here the Topaz 9points font is used and the script waits until the left
  77.  * mousebutton is pressed before showing the next file. (if any are left.)
  78.  *
  79.  * Make sure 'No filename quote',  'Reload each file' & 'Do all files' are
  80.  * selected as options.
  81.  *
  82.  * For more info on installing tools in Directory Opus please consult it's
  83.  * manual.
  84.  *
  85.  * Send suggestions and problemreports to: boinger@myamy.hacktic.nl
  86.  *                                         paulk@stack.urc.tue.nl
  87.  *
  88.  */
  89.  
  90. /* Parse the arguments */
  91. PARSE ARG name font size wait
  92.  
  93. IF font = 'font' | font = '' | font = 'FONT' THEN font = 0
  94. IF wait = 'wait' | wait = '' | wait = 'WAIT' THEN wait = 50
  95.  
  96. IF size = 0 | size = 'size' | size = 'SIZE' THEN size = 8
  97.  
  98. /* Set the ToolTypes. -- ATTN: Adjust to your configuration and liking -- */
  99. diaName = 'egs:Piccolo/Dia/Dia "SCREEN=PICOa:SVGA 800x600" DELAY='||wait||'
  100. DEPTH=16 
  101. ZOOM=ON AUTOCLEAR=ON'; 
  102.  
  103. /* We need the rexxsupport.library, so check if it's there */ 
  104. IF( ~SHOW( 'L', "rexxsupport.library" ) ) THEN DO
  105.         IF( ~ADDLIB("rexxsupport.library", 0, -30, 0 )) THEN DO
  106.                 EXIT
  107.         END
  108. END
  109.  
  110. /* Now check if the specified font exists, and if the size is valid. */
  111. /* If an invalid font is specified, then use default topaz 8         */
  112.  
  113. IF font ~=0 & font ~= "topaz.font" THEN DO
  114.         IF EXISTS("Fonts:" || font) THEN DO
  115.                 tmp = POS(".font", font)
  116.                 IF tmp ~= 0 THEN DO
  117.                         fontname = DELSTR(font,tmp) 
  118.                         IF ~EXISTS("Fonts:" || fontname || "/"size) THEN DO
  119.                                 tmp=SHOWDIR("Fonts:" || fontname, 'f')
  120.                                 size=STRIP(LEFT(tmp, 2))
  121.                         END
  122.                 END
  123.         END
  124.         ELSE DO
  125.                 fontname = "topaz.font"
  126.                 size = 8
  127.         END
  128. END
  129.                         
  130.  
  131. OPTIONS RESULTS
  132.  
  133. Max_Seconds_To_Load = 60
  134. Flag = 0
  135.  
  136. /* Check if Dia is already running. If not, then start it up. */
  137. TIME( 'R' )
  138. DO WHILE (TIME( 'E' ) < Max_Seconds_To_Load) & (POS( 'rainbow', SHOW( 'Ports' ) ) = 0)
  139.         IF Flag = 0 THEN DO
  140.                 /* Set whatever command line arguments you want. */
  141.                 ADDRESS COMMAND 'run <nil: >nil: ' || diaName;
  142.                 Flag = 1
  143.         END
  144.         ADDRESS COMMAND 'WAIT 1'
  145. END
  146.  
  147. IF POS( 'rainbow', SHOW( 'Ports' ) ) = 0 THEN
  148. DO
  149.         SAY "Failed!"
  150.         EXIT
  151. END
  152. ELSE DO
  153. /* Now we load the picture */
  154.         path=PRAGMA('D','')
  155.         /* check if path is given, otherwise add current path to name
  156.          */
  157.         if ~ ((VERIFY('/',name)==0) | (VERIFY(':',name)==0)) THEN DO
  158.            name=path || '/' || name
  159.         END
  160.  
  161.         IF EXISTS(name) THEN DO                         /* existing File ? */
  162.                 address "rainbow";
  163.  
  164.                 SAY "loading " || name || "..."
  165.                 AUTOCLEAR ON
  166.                 SCROLLING ON
  167.                 COLOR 0 0 0
  168.                 BCOLOR 170 170 170
  169.                 OPEN name                               /* If yes, load Picture */
  170.                 IF font ~= 0 THEN DO                    /* Display Filename?  */
  171.                    DMODE 1
  172.                    SFNAME font
  173.                    SETFONT size 0
  174.                    MOVE 2 2
  175.                    TEXT name
  176.                 END
  177.                 If wait = 0 THEN CALL Scrollem             /* Wait for mouseclick? */
  178.         END
  179.         ELSE DO
  180.                 say name || " doesn't exist."
  181.         END
  182. END
  183.  
  184. EXIT
  185.  
  186. /* T-t-t-that's all f-f-f-folks! Y'awl come back now, ya hear. */
  187. /*---------------------------- Subroutine Section ---------------------------*/
  188. Scrollem:
  189. /* In this subroutine we allow the user to scroll around the picture if it is */
  190. /* larger than the screen.  */
  191.  
  192. OPTIONS RESULTS
  193. GET_SW
  194. scx = result
  195. GET_SH
  196. scy = result
  197. GET_W
  198. picx = result
  199. GET_H
  200. picy = result
  201.  
  202. /*
  203.  debug info... Uncomment if you like to see what's going on.
  204. say 'Screen Width : ' || scx
  205. say 'Screen Height: ' || scy
  206. say 'Picture Width: ' || picx
  207. say 'PictureHeight: ' || picy
  208.   end of debug info
  209. */
  210.  
  211. einde = 0
  212. SCROLLING ON
  213. xpos = 0
  214. ypos = 0
  215. DO WHILE einde = 0
  216.         WAITMOUSE                         /* Wait for mouseclick? */
  217. /* If clicked, we get the mouse x and y coordinate */
  218.  
  219.         OPTIONS RESULTS
  220.         GET_MX
  221.         mx = result
  222.         GET_MY
  223.         my = result
  224. /*
  225.   some more debug info...
  226.         say 'Mouse X pos. : ' || mx
  227.         say 'Mouse Y pos. : ' || my
  228.         say 'Pict. X pos  : ' || xpos
  229.         say 'Pict. Y pos  : ' || ypos
  230.   end the end of it
  231. */
  232.  
  233. /* Clicked in the rightmost 25 pixels so we scroll to the left */
  234.         IF (scx - mx) <= 25 THEN DO
  235.                 xpos = xpos + 25
  236.                 IF xpos > (picx - scx) THEN xpos = picx - scx
  237.                 SCROLLTO xpos ypos    /* Scroll Right */
  238.         END
  239.  
  240. /* Clicked in the leftmost 25 pixels, so we scroll to the right */
  241.         IF mx <= 25         THEN DO
  242.                 xpos = xpos - 25
  243.                 IF xpos < 0 THEN xpos = 0
  244.                 SCROLLTO xpos ypos     /* Scroll Left  */
  245.         END
  246.  
  247. /* Clicked in the uppermost 25 pixels, so we scroll down */
  248.         IF my <= 25 & mx > 25 & (scx - mx) > 25 THEN DO
  249.                 ypos = ypos - 25
  250.                 IF ypos < 0 THEN ypos = 0    
  251.                 SCROLLTO xpos ypos     /* Scroll Down  */
  252.         END
  253.  
  254. /* Clicked in the lowermost 25 pixels, so we scroll up */
  255.         IF (scy - my) <= 25 & mx > 25 & (scx - mx) > 25 THEN DO
  256.                 ypos = ypos + 25
  257.                 IF ypos > (picy - scy) THEN ypos = picy - scy  
  258.                 SCROLLTO xpos ypos       /* Scroll Up    */
  259.         END
  260.  
  261. /* Clicked out of the scroll boxes. Means we exit this scroll routine */
  262.         IF (scx - mx) > 25 & mx > 25 & my > 25 & (scy - my) > 25 THEN
  263.                 einde = 1          /* Exit the scroll routine */
  264. END
  265.                          
  266. RETURN
  267.